﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ServiceModel;
using RilattackLibrary;
using System.Threading;
using System.Timers;

namespace RilattackGameWPF
{
    /// <summary>
    /// Logique d'interaction pour MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window { 

        public static RilattackGame Game;

        public MainWindow()
        {
            System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(this);
            InitializeComponent();
            serveurEndpoint.Text = "net.tcp://" + System.Configuration.ConfigurationManager.AppSettings["ServerDefaultIP"] + ':' + System.Configuration.ConfigurationManager.AppSettings["ServerDefaultPort"] + "/RilAttack";
            NickName.Text = "Player";
            App.Window = this;
        }

        private void connexionBtn_Click(object sender, RoutedEventArgs e)
        {
            App.ConnectToLobby();
        }

        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);
        }


        public void LaunchGame()
        {
            System.Timers.Timer aTimer = new System.Timers.Timer();
            aTimer.Elapsed += new ElapsedEventHandler(new InputManager().CheckInput);

            aTimer.Interval = 10;
           
            Game = new RilattackGame();

            aTimer.Enabled = true;
            Game.Run();
        }
    }
}
